package com.java.tutorials.jdk7.files;

import java.io.IOException;
import java.nio.file.*;

/**
 * Created by xuzhike on 2016/1/26.
 * http://www.java2s.com/Code/Java/JDK-7/Filteringadirectoryusingglobbing.htm
 * Filtering a directory using globbing
 */
public class Filteringadirectoryusingglobbing {
    public static void main(String[] args) {
        Path directory = Paths.get("D:\\DevelopmentTools\\JAVA\\jdk1.8.0_66\\bin");
        try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(
                directory, "java*.exe")) {
            for (Path file : directoryStream) {
                System.out.println(file.getFileName());
            }
        } catch (IOException | DirectoryIteratorException ex) {
            ex.printStackTrace();
        }

    }
}
